import java.util.*;

public class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        boolean[] flag = new boolean[n];
        int count = 0;
        for (int i = 0; i < m; i++) {
            int x = in.nextInt();
            int y = in.nextInt();
            int z = in.nextInt();

            if(!flag[x-1] && !flag[y-1]) {
                count++;
            }
            flag[x-1] = true;
            flag[y-1] = true;
        }
        for(int i = 0; i < n; i++) {
            if(!flag[i]) {
                count++;
            }
        }
        System.out.println(count);
    }
}
